www.gusucode.com > VC 串口通讯_数据库存取例子-源码程序 > VC 串口通讯_数据库存取例子-源码程序/code/Modem3/JiebingDialog.cpp

    //Download by http://www.NewXing.com
// JiebingDialog.cpp : implementation file
//

#include "stdafx.h"
#include "Modem3.h"
#include "JiebingDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CJiebingDialog dialog


CJiebingDialog::CJiebingDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CJiebingDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CJiebingDialog)
	m_bzy = 0;
	m_cys = 0;
	m_djqr = 0;
	m_djrj = 0;
	m_eys = 0;
	m_gjqr = 0;
	m_gjrj = 0;
	m_rjgfwd = 0;
	m_rjwdd = 0;
	m_rjwdu = 0;
	m_rybpl = 0;
	m_tgfwd = 0;
	//}}AFX_DATA_INIT
	CWnd *ppWnd=CWnd::FindWindow(NULL,"modem3");
    pWnd=((CModem3Dlg *)ppWnd);
}


void CJiebingDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CJiebingDialog)
	DDX_Text(pDX, IDC_BZY, m_bzy);
	DDX_Text(pDX, IDC_CYS, m_cys);
	DDV_MinMaxInt(pDX, m_cys, 10, 120);
	DDX_Text(pDX, IDC_DJQR, m_djqr);
	DDV_MinMaxInt(pDX, m_djqr, 60, 240);
	DDX_Text(pDX, IDC_DJRJ, m_djrj);
	DDV_MinMaxInt(pDX, m_djrj, 2, 15);
	DDX_Text(pDX, IDC_EYS, m_eys);
	DDV_MinMaxInt(pDX, m_eys, 10, 120);
	DDX_Text(pDX, IDC_GJQR, m_gjqr);
	DDV_MinMaxInt(pDX, m_gjqr, 30, 240);
	DDX_Text(pDX, IDC_GJRJ, m_gjrj);
	DDV_MinMaxInt(pDX, m_gjrj, 7, 30);
	DDX_Text(pDX, IDC_RJGFWD, m_rjgfwd);
	DDV_MinMaxInt(pDX, m_rjgfwd, 120, 160);
	DDX_Text(pDX, IDC_RJWDD, m_rjwdd);
	DDV_MinMaxInt(pDX, m_rjwdd, 10, 30);
	DDX_Text(pDX, IDC_RJWDU, m_rjwdu);
	DDV_MinMaxInt(pDX, m_rjwdu, 130, 150);
	DDX_Text(pDX, IDC_RYBPL, m_rybpl);
	DDV_MinMaxInt(pDX, m_rybpl, 20, 40);
	DDX_Text(pDX, IDC_TGFWD, m_tgfwd);
	DDV_MinMaxInt(pDX, m_tgfwd, 140, 160);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CJiebingDialog, CDialog)
	//{{AFX_MSG_MAP(CJiebingDialog)
	ON_BN_CLICKED(IDC_YINGYONG, OnYingyong)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CJiebingDialog message handlers

BOOL CJiebingDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
    int i;
	for(i=0;i<23;i++)
		yd[i]=pWnd->immediate_data[i];
	 m_rjgfwd=yd[7];
	 m_rybpl=yd[8];
	 m_gjqr=yd[9];
	 m_djqr=yd[10];
	 m_tgfwd=yd[11];
	 m_rjwdu=yd[12];
	 m_rjwdd=yd[13];
	 m_gjrj=yd[16]+yd[17]*256;
	 m_djrj=yd[18];
	 m_cys=yd[14];
	 m_eys=yd[15];
	// TODO: Add extra initialization here
	this->UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CJiebingDialog::OnOK() 
{
	// TODO: Add extra validation here


     CDialog::OnOK();
}

void CJiebingDialog::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CJiebingDialog::OnYingyong() 
{
	// TODO: Add your control notification handler code here
	int i;
	this->UpdateData(TRUE);
	pWnd->send_data[0]=0xf7;
	pWnd->send_data[1]=0xf8;
	pWnd->send_data[2]=0x12;
	pWnd->send_data[3]=0x01;
	pWnd->send_data[4]=yd[4];
	pWnd->send_data[5]=0x38;
	for(i=6;i<20;i++)
	pWnd->send_data[i]=pWnd->send_data[i+1];
	pWnd->send_data[6]=int(m_rjgfwd);
    pWnd->send_data[7]=int(m_rybpl);
	pWnd->send_data[8]=int(m_gjqr);
	pWnd->send_data[9]=int(m_djqr);
	pWnd->send_data[10]=int(m_tgfwd);
	pWnd->send_data[11]=int(m_rjwdu);
	pWnd->send_data[12]=int(m_rjwdd);
	pWnd->send_data[13]=int( m_cys);
	pWnd->send_data[14]=int(m_eys);
	pWnd->send_data[15]=int(m_gjrj);
	pWnd->send_data[17]=int(m_djrj);
	pWnd->send_data[20]=0;
	for(i=2;i<20;i++)
		pWnd->send_data[20]=+pWnd->send_data[i];
	pWnd->send_data[21]=0xfd;
	pWnd->send_flag=1;
}